########################################################################################
@model[]
########################################################################################

^if( 
	$form:objectTypeId &&
	$form:dealTypeId &&
	^form:metricArea.int(0) &&
	$form:regionId &&
	def $form:description &&
	$form:stationId &&
	^form:price.int(0) &&
	$form:contactId
){
	^oSensus.data.insert[commercial]
}

########################################################################################



########################################################################################
@view[]
########################################################################################

<h1>Коммерческая недвижимость / Добавление объекта</h1>
<form method="post">
	^if( $oSensus.data.latestId ){ <div class="green">Объект успешно добавлен</div> }
	<table>
		<tr>
			<td class="aRight"><label for="objectTypeId">Тип объекта</label></td>
			<td>
				^oSensus.interface.select[
					$.name[objectTypeId]
					$.table[^oSensus.data.table{ SELECT id, name FROM objectTypeList WHERE id NOT IN ( 1, 2 ) ORDER BY name }]					
					^if( $oSensus.data.latestId ){ $.reset(true) }
				]
			</td>
			<td class="aRight"><label for="dealTypeId">Тип сделки</label></td>
			<td>
				^oSensus.interface.select[
					$.name[dealTypeId]
					$.table[^oSensus.data.dictionary[dealTypeList]]
					^if( $oSensus.data.latestId ){ $.reset(true) }
				]
			</td>
		</tr>
		<tr>
			<td class="aRight"><label for="metricArea">Метраж, м.<sup>2</sup></label></td>
			<td><input name="metricArea" id="metricArea" value="^if(!$oSensus.data.latestId){$form:metricArea}" /></td>
			<td class="aRight"><label for="regionId">Регион</label></td>
			<td>
				^oSensus.interface.select[
					$.name[regionId]
					$.table[^oSensus.data.dictionary[regionList]]
					^if( $oSensus.data.latestId ){ $.reset(true) }
				]
			</td>
		</tr>
		<tr>
			<td class="aRight"><label for="description">Описание</label></td>
			<td><textarea name="description" id="description">^if(!$oSensus.data.latestId){$form:description}</textarea></td>
			<td class="aRight"><label for="stationId">Метро</label></td>
			<td>
				^oSensus.interface.select[
					$.name[stationId]
					$.table[^oSensus.data.dictionary[stationList]]
					^if( $oSensus.data.latestId ){ $.reset(true) }
				]
			</td>
		</tr>
		<tr>
			<td class="aRight"><label for="price">Цена в рублях</label></td>
			<td><input name="price" id="price" value="^if(!$oSensus.data.latestId){$form:price}" /></td>
			<td class="aRight"><label for="contactId">Контакт</label></td>
			<td>
				^oSensus.interface.select[
					$.name[contactId]
					$.table[^oSensus.data.dictionary[contactList]]
					^if( $oSensus.data.latestId ){ $.reset(true) }
				]
			</td>
		</tr>
		<tr>
			<td colspan="4" class="aRight">
				<input type="submit" value="Добавить" />
			</td>
		</tr>
	</table>
</form>

########################################################################################